package Controllers;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import Database.mysqlConnection;
import MessagePacks.GetAllPack;

/**
 *@author Juan Alapin - 324507516
 *@author Giora Yaffe - 036551281
 *@author Shachar Gritzman - 300174026
 *@author Nir Porat - 021515580
*/

public class ReportsController {

	public ReportsController(){}
	
	/**
	 * Retrieve estimator report
	 * @param proID - The process ID
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 * @return ArrayList<String>
	 */
	public ArrayList<String> getEsReport(int proID,mysqlConnection SqlDB)
	{
	 return(SqlDB.getEsReportFromDB(proID));
	}
	
	/**
	 * Retrieve all estimator's reports
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 * @return ArrayList<String>
	 */
	public ArrayList<String> getAllEsReport(mysqlConnection SqlDB)
	{
	 return(SqlDB.getAllEsReportFromDB());
	}
	
	/**
	 * Get report from committee member 1
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 * @return ArrayList<String>
	 */
	public ArrayList<String> getEsReportMem1(mysqlConnection SqlDB){
		
		try {
			return SqlDB.getAllReportsMem1();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null; 

	}
	
	/**
	 *  Get report from committee member 2
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 * @return ArrayList<String>
	 */
	public ArrayList<String> getEsReportMem2(mysqlConnection SqlDB){
		
		try {
			return SqlDB.getAllReportsMem2();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;  

	}
	
	/**
	 * Sets the read of the report to OK from a committee member
	 * @param memNum - Member number
	 * @param repID - Report's ID
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 */
	public void setRepReadApprove(int memNum, int repID, mysqlConnection SqlDB) {
		SqlDB.updateReportRead(memNum,repID);
	}
	
	/**
	 * Check if the report have been read
	 * @param reportId - Report's ID
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 * @return 1 - OK , 0 - otherwise
	 */
	public int CheckEstRepRead(int reportId, mysqlConnection SqlDB) {
		int ans=0;
		ans=SqlDB.CheckReadEstRep(reportId);
		return ans;
	}
	
	/**
	 * Delete Estimator report
	 * @param reportID - Report's ID
	 * @param SqlDB:mysqlConnection - SQL DataBase
	 * @return 1 - OK , 0 - otherwise
	 */
	public int DelEsReport(int reportID, mysqlConnection SqlDB) {
		int ans=0;
		ans=SqlDB.delEsReport(reportID);
		return ans;
	}


}
